package cn.itcast.hiss.server.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/*
 * 商品用到的表
 **/
@Mapper
public interface GoodsMapper {

    @Select("select * from ts_goods where (num/stock_count)<0.2 and sales>0")
    public List<Map<String, Object>> listGoods();

    @Select("select count(1) from ts_goods where (num/stock_count)<0.2 and sales>0")
    public int countGoods();

    @Update("update ts_goods set stock_count=stock_count+#{num},num=num+#{num} where id=#{id}")
    public int updateStock(int id,int num);

}
